package au.com.handsunited.model.relationship;


/**
 *
 * @author arunda
 */
public enum RelationshipStatus {

	ACTIVE ("Active"),

	INACTIVE ("Inactive"),

	AWAITING_AUTHORISATION ("AwaitingAuthorisation"),

	ACTION_PENDING("ActionPending"),

	UNKNOWN("Unknown");

	/**
	 *
	 */
	private final String name;

	/**
	 *
	 * @param name
	 */
	private RelationshipStatus(String name) {
		this.name = name;
	}

	/**
	 *
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * @see java.lang.Enum#toString()
	 */
	@Override
	public String toString() {
		return "Status[" + name + "]";
	}

	/**
	 *
	 * @param statusStr
	 * @return
	 */
	public static RelationshipStatus fromString(String statusStr) {

		if (ACTIVE.name.equalsIgnoreCase(statusStr)) {
			return ACTIVE;
		} else if (INACTIVE.name.equalsIgnoreCase(statusStr)) {
			return INACTIVE;
		} else if (AWAITING_AUTHORISATION.name.equalsIgnoreCase(statusStr)) {
			return AWAITING_AUTHORISATION;
		} else if (ACTION_PENDING.name.equalsIgnoreCase(statusStr)) {
			return ACTION_PENDING;
		} else if (UNKNOWN.name.equalsIgnoreCase(statusStr)) {
			return UNKNOWN;
		} else {
			return UNKNOWN;
		}
	}


	public boolean isActive() {
		return name.equals(ACTIVE.name);
	}

	public boolean isInactive() {
		return name.equals(INACTIVE.name);
	}

	public boolean isAwaitingAuthorisation() {
		return name.equals(AWAITING_AUTHORISATION.name);
	}

	public boolean isActionPending() {
		return name.equals(ACTION_PENDING.name);
	}

	public boolean isUnknown() {
		return name.equals(UNKNOWN.name);
	}
}
